package models;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import net.ufrog.common.utils.Strings;

/**
 * 图文信息模型
 * 
 * @author ultrafrog
 * @version 1.0, 2014-11-28
 * @since 1.0
 */
@Entity
@Table(name = "uwx_article")
public class Article extends Model {

	/** 标题 */
	@Column(name = "vc_title")
	public String title;
	
	/** 作者 */
	@Column(name = "vc_author")
	public String author;
	
	/** 概述 */
	@Column(name = "vc_description")
	public String description;
	
	/** 图片地址 */
	@Column(name = "vc_pic_url")
	public String picUrl;
	
	/** 文本 */
	@Column(name = "vc_text")
	public String text;
	
	/** 时间 */
	@Column(name = "dt_datetime")
	public Date datetime;
	
	/** 构造函数 */
	public Article() {
		datetime = new Date();
	}
	
	/**
	 * 保存
	 * 
	 * @param title
	 * @param author
	 * @param description
	 * @param picUrl
	 * @param text
	 * @return
	 */
	public Article save(String title, String author, String description, String picUrl, String text) {
		this.title = title;
		this.author = Strings.empty(author, null);
		this.description = description;
		this.picUrl = picUrl;
		this.text = text;
		this.save();
		
		return this;
	}
}
